home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 405_01 / flexpp / testscan.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-24  |  7.2 KB  |  252 lines

  1. #define FLEX_DEBUG
  2. #define YY_CHAR unsigned char
  3. # line 1 "/u/coetmeur/tools/flex++2/flexskel.cc"
  4. /* A lexical scanner generated by flex */
  5. /* scanner skeleton version:
  6.  * $Header: /usr/fsys/odin/a/vern/flex/RCS/flex.skel,v 2.16 90/08/03 14:09:36 vern Exp $
  7.  */
  8. /* MODIFIED FOR C++ CLASS BY Alain Coetmeur: coetmeur(at)icdc.fr */
  9. /* Note that (at) mean the 'at' symbol that I cannot write */
  10. /* because it is expanded to the class name */
  11. /* made at Informatique-CDC, Research&development department */
  12. /* company from the Caisse Des Depots et Consignations */
  13. /* institutional financial group (say 'Cat Doc Cad') */
  14.  
  15. /* theses symbols are added before this file */
  16. /* #define YY_CHAR 'unsigned char' if 8bit or 'char' if 7bit */
  17. /* #define FLEX_DEBUG if debug mode */
  18. #define FLEX_SCANNER
  19. /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
  20. #ifdef c_plusplus
  21. #ifndef __cplusplus
  22. #define __cplusplus
  23. #endif
  24. #endif
  25. #ifdef __cplusplus
  26. #include <stdlib.h>
  27. #define YY_USE_CONST
  28. char *malloc();
  29. int free();
  30. int read();
  31. #define YY_USE_PROTOS
  32. #include <osfcn.h>
  33. #else    /* ! __cplusplus */
  34. #ifdef __STDC__
  35. #ifdef __GNUC__
  36. #include <stddef.h>
  37. void *malloc( size_t );
  38. void free( void* );
  39. int read();
  40. #else
  41. #define YY_USE_CONST
  42. #include <stdlib.h>
  43. char *malloc();
  44. int free();
  45. int read();
  46. #endif    /* __GNUC__ */
  47. #define YY_USE_PROTOS
  48. #endif    /* __STDC__ */
  49. #endif    /* ! __cplusplus */
  50. #ifdef __TURBOC__
  51. #define YY_USE_CONST
  52. #endif
  53. #include <stdio.h>
  54. /*********************************************/
  55. /* COMPILER DEPENDENT   MACROS               */
  56. /*********************************************/
  57. /* use prototypes in function declarations */
  58. /* the "const" storage-class-modifier is valid */
  59. #ifndef YY_USE_CONST
  60. #define const
  61. #endif
  62. /* use prototypes in function declarations */
  63. #ifndef YY_PROTO
  64. #ifdef YY_USE_PROTOS
  65. #define YY_PROTO(proto) proto
  66. #else
  67. #define YY_PROTO(proto) ()
  68. #endif
  69. #endif
  70.  
  71.  
  72. /*********************/
  73. /* parameters        */
  74.  
  75. /* amount of stuff to slurp up with each read */
  76. #ifndef YY_READ_BUF_SIZE
  77. #define YY_READ_BUF_SIZE 8192
  78. #endif
  79. /* size of default input buffer */
  80. #ifndef YY_BUF_SIZE
  81. #define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) 
  82. #endif
  83.  
  84. /***********************************/
  85. /* to be redefined for application */
  86.  
  87. /* returned upon end-of-file */
  88. #define YY_END_TOK 0
  89. /* no semi-colon after return; correct usage is to write "yyterminate();" -
  90.  * we don't want an extra ';' after the "return" because that will cause
  91.  * some compilers to complain about unreachable statements.
  92.  */
  93. #define yyterminate() return ( YY_NULL )
  94.  
  95. /* code executed at the end of each rule */
  96. #define YY_BREAK break;
  97.  
  98. /* #define YY_USER_ACTION */
  99. /* #define YY_USER_INIT */
  100.  
  101.  
  102. #ifndef YY_USE_CLASS
  103. /* copy whatever the last rule matched to the standard output */
  104. /* cast to (char *) is because for 8-bit chars, yytext is (unsigned char *) */
  105. /* this used to be an fputs(), but since the string might contain NUL's,
  106.  * we now use fwrite()
  107.  */
  108. #define ECHO (void) fwrite( (char *) yytext, yyleng, 1, yyout )
  109.  
  110. /* gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
  111.  * is returned in "result".
  112.  */
  113. #define YY_INPUT(buf,result,max_size) \
  114.     if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \
  115.         YY_FATAL_ERROR( "read() in flex scanner failed" );
  116.  
  117. /* report a fatal error */
  118.  
  119. /* The funky do-while is used to turn this macro definition into
  120.  * a single C statement (which needs a semi-colon terminator).
  121.  * This avoids problems with code like:
  122.  *
  123.  *     if ( something_happens )
  124.  *        YY_FATAL_ERROR( "oops, the something happened" );
  125.  *    else
  126.  *        everything_okay();
  127.  *
  128.  * Prior to using the do-while the compiler would get upset at the
  129.  * "else" because it interpreted the "if" statement as being all
  130.  * done when it reached the ';' after the YY_FATAL_ERROR() call.
  131.  */
  132.  
  133. #define YY_FATAL_ERROR(msg) \
  134.     do \
  135.         { \
  136.         (void) fputs( msg, stderr ); \
  137.         (void) putc( '\n', stderr ); \
  138.         exit( 1 ); \
  139.         } \
  140.     while ( 0 )
  141.  
  142. /* default yywrap function - always treat EOF as an EOF */
  143. #define yywrap() 1
  144.  
  145.  
  146. /* default declaration of generated scanner - a define so the user can
  147.  * easily add parameters
  148.  */
  149. #define YY_DECL int yylex YY_PROTO(( void )) 
  150. #else 
  151. /* c++ */
  152. #define ECHO (void) fwrite( (char *) yytext, yyleng, 1, yyout )
  153. #define YY_INPUT(buf,result,max_size) \
  154.     if ( yy_input((char *)buf, result,max_size) < 0 ) \
  155.         YY_FATAL_ERROR( "yy_input() in flex scanner failed" );
  156.  
  157. #define YY_FATAL_ERROR(msg) yy_fatal_error(msg)
  158. #define yywrap() yy_wrap()
  159.  
  160. #endif
  161. /***********************************/
  162. /* not to be changed */
  163. #define YY_NULL 0
  164. #define YY_END_OF_BUFFER_CHAR 0
  165. /* special action meaning "start processing a new file" */
  166. #define YY_NEW_FILE \
  167.     do \
  168.         { \
  169.         yy_init_buffer( yy_current_buffer, yyin ); \
  170.         yy_load_buffer_state(); \
  171.         } \
  172.     while ( 0 )
  173. /* enter a start condition.  This macro really ought to take a parameter,
  174.  * but we do it the disgusting crufty way forced on us by the ()-less
  175.  * definition of BEGIN
  176.  */
  177. #define BEGIN yy_start = 1 + 2 *
  178.  
  179. /* action number for EOF rule of a given start state */
  180. #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
  181.  
  182.  
  183.  
  184. /* % section 1 definitions go here */ 
  185. # line 1 "scan.l"
  186. #define INITIAL 0
  187. /* scan.l - scanner for flex input */
  188. # line 5 "scan.l"
  189. /*-
  190.  * Copyright (c) 1990 The Regents of the University of California.
  191.  * All rights reserved.
  192.  *
  193.  * This code is derived from software contributed to Berkeley by
  194.  * Vern Paxson.
  195.  * 
  196.  * The United States Government has rights in this work pursuant
  197.  * to contract no. DE-AC03-76SF00098 between the United States
  198.  * Department of Energy and the University of California.
  199.  *
  200.  * Redistribution and use in source and binary forms are permitted provided
  201.  * that: (1) source distributions retain this entire copyright notice and
  202.  * comment, and (2) distributions including binaries display the following
  203.  * acknowledgement:  ``This product includes software developed by the
  204.  * University of California, Berkeley and its contributors'' in the
  205.  * documentation or other materials provided with the distribution and in
  206.  * all advertising materials mentioning features or use of this software.
  207.  * Neither the name of the University nor the names of its contributors may
  208.  * be used to endorse or promote products derived from this software without
  209.  * specific prior written permission.
  210.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  211.  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  212.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  213.  */
  214.  
  215. #ifndef lint
  216. static char rcsid[] =
  217.     "@(#) $Header: /usr/fsys/odin/a/vern/flex/RCS/scan.l,v 2.9 90/06/27 23:48:34 vern Exp $ (LBL)";
  218. #endif
  219.  
  220. #undef yywrap
  221.  
  222. #include "flexdef.h"
  223. #include "parse.h"
  224.  
  225. #define HEADER_ECHO fprintf(headerfile,"%s",yytext )
  226. #define ACTION_ECHO fprintf( temp_action_file, "%s", yytext )
  227. #define MARK_END_OF_PROLOG fprintf( temp_action_file, "%%%% end of prolog\n" );
  228.  
  229. #undef YY_DECL
  230. #define YY_DECL \
  231.     int flexscan()
  232.  
  233. #define RETURNCHAR \
  234.     yylval = yytext[0]; \
  235.     return ( CHAR );
  236.  
  237. #define RETURNNAME \
  238.     (void) strcpy( nmstr, (char *) yytext ); \
  239.     return ( NAME );
  240.  
  241. #define PUT_BACK_STRING(str, start) \
  242.     for ( i = strlen( (char *) (str) ) - 1; i >= start; --i ) \
  243.         unput((str)[i])
  244.  
  245. #define CHECK_REJECT(str) \
  246.     if ( all_upper( str ) ) \
  247.         reject = true;
  248.  
  249. #define CHECK_YYMORE(str) \
  250.     if ( all_lower( str ) ) \
  251.         yymore_used = true;
  252.